package com.cscp.javastudy.basic.annotation;

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

/**
 * 自定义注解
 */
public class AnnotationDemo2 {

    @MyAnnotation2(age = 20)
    public void testMyAnno(){

    }

    @MyAnnotation3("shannxi")
    public void testMyAnno2(){

    }
}

@Target(value = {ElementType.TYPE,ElementType.METHOD})
@Retention(value = RetentionPolicy.RUNTIME)
@interface MyAnnotation2{

    // 注解的参数
    String name() default "";
    int age() default 0;
    int id() default -1;// -1代表不存在
    String[] schools() default {"清华大学","北京大学"};
}

@Target(value = {ElementType.TYPE,ElementType.METHOD})
@Retention(value = RetentionPolicy.RUNTIME)
@interface MyAnnotation3{
    String value();
}